<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>打印菱形</title>
</head>
<body>
    <script type="text/javascript">
        var n=window.prompt("请输入行数"); 
        for(i=1;i<=n;i++){
            for(j=1;j<=n-i;j++){
                document.write("&nbsp;");
            }
            for(k=1;k<=2*i-1;k++){
                document.write("a");
            }
            document.write("<br/>");
        }
        for(i=1;i<=n;i++){
            for(j=1;j<=i;j++){
                document.write("&nbsp;");
            }
            for(k=1;k<=2*(n-i)-1;k++){ 
                document.write("a");
            }
            document.write("<br/>");
        }
    </script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>打印菱形、三角形</title>
</head>
<body>
    <script type="text/javascript">
        for(var j=1;j<4;j++)
        {
            for(var i=1;i<=j;i++)
            {
                document.write("a");
            }
            document.write("<br/>");
        }
    </script>
</body>
</html>